{template 'common/header'}
<style>

.table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
white-space: normal;
word-wrap: break-word;
word-break: normal;
}

</style>
<script src="{MODULE_URL}/template/static/js/mzp-packed-me.js"></script>
<div class="main">
    <ul class="nav nav-tabs">
        <li{if $_GPC['do'] == 'manage' || $_GPC['do'] == '' } class="active"{/if}><a href="{php echo $this->createWebUrl('manage');}">活动管理</a></li>
        <li{if $_GPC['do'] == 'post'} class="active"{/if}><a href="{php echo url('platform/reply/post',array('m'=>'tyzm_diamondvote'));}">添加活动规则</a></li>
    </ul>
    
 
    <div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
        	<input type="hidden" name="m" value="tyzm_diamondvote" />
        	<input type="hidden" name="do" value="manage" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-9">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
				</div>
                                <div class=" col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
 			<div class="form-group">
			</div>
		</form>
	</div>
 
    </div>
  <div class="panel panel-default">
    <div style="padding:15px;">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr><th class='with-checkbox' style="width:20px;">
                    <input type="checkbox" class="check_all" /></th>
                    <th>活动名称</th>
					<th>活动链接</th>
					<th>参与人数</th>
                    <th>投票数量</th>
					<th>礼物</th>
                    <th>浏览量</th>
					<th>分享量</th>
                    <th>开始时间/结束时间</th>
                    <th>状态</th>  
                    <th>操作</th>
                </tr>
            </thead>
            <tbody class="listbox">
                {loop $list $row}
                <tr>

                    <td class="with-checkbox">
                        <input type="checkbox" name="check" value="{$row['id']}"></td>	
						<td>{$row['title']} </td>
						<td class="js-url"> <a href="{php echo $_W['siteroot'].'app/' }{php echo $this->createMobileUrl('index',array('rid'=>$row['rid']))}" data-url="{php echo $_W['siteroot'].'app/' }{php echo $this->createMobileUrl('index',array('rid'=>$row['rid']))}" class="btn  btn-default " rel="tooltip" title="" target="_blank"><i class="fa fa-cog"></i>活动链接</a></td>
                    <td><span class="label label-primary">{$row['jointotal']}</span></td>
					<td><span class="label label-info">{$row['votetotal']}</span></td> 
					<td><span class="label label-success">{$row['giftcount']}元</span></td> 
					<td><span class="label label-danger">{$row['pvtotal']}</span></td>
					<td><span class="label label-warning">{$row['sharetotal']}</span></td>
                    <td>{php echo date('Y-m-d H:i:s',$row['starttime'])}<br>
                        {php echo date('Y-m-d H:i:s',$row['endtime'])}</td>
                    <td>
					    {if $row['status']==1}
						  <span class="label label-success">开始</span>
						{elseif $row['status']==3}
						  <span class="label label-warning">未开始</span>
						{elseif $row['status']==4}
						  <span class="label label-default">已结束</span>
						{else}
						  <span class="label label-danger">已关闭</span>
						{/if}
					
					</td>
                    <td >
                   
                    <a href="{php echo $this->createWebUrl('votelist',array('rid'=>$row['rid']))}" class="btn  btn-default" rel="tooltip" title="投票管理"><i class="fa fa-cog"></i>投票管理</a>
					</br>
					{if $row['config']['isredpack']==1}
					<a href="{php echo $this->createWebUrl('lottery',array('rid'=>$row['rid']))}" class="btn  btn-default" rel="tooltip" title="红包管理"><i class="fa fa-money"></i>红包管理</a>
					</br>
					{/if}
                        <a class="btn btn-default" rel="tooltip" href="{php echo url('platform/reply/post',array('m'=>'tyzm_diamondvote','rid'=>$row['rid']));}" title="编辑"><i class="fa fa-edit"></i></a>
                        {if $row['status']==0}
                        <a class="btn   btn-default" title="开始活动" href="#" onclick="drop_confirm('您确定要开始活动吗!', '{php echo $this->createWebUrl('otherset',array('ty'=>'setstatus','rid'=>$row['rid'],'status'=>1))}');"><i class="fa fa-play"></i></a>
                        {else}
                        <a class="btn   btn-default" title="关闭活动" href="#" onclick="drop_confirm('您确定要暂停活动吗？', '{php echo $this->createWebUrl('otherset',array('ty'=>'setstatus','rid'=>$row['rid'],'status'=>0))}');"><i class="fa fa-stop"></i></a>
                        {/if}
                        <a class="btn  btn-danger" rel="tooltip" href="#" onclick="drop_confirm('您确定要删除吗?删除不可恢复。', '{php echo url('platform/reply/delete',array('m'=>'tyzm_diamondvote','rid'=>$row['rid']));}');" title="删除"><i class="fa fa-times"></i></a> 
                  
                       
                    </td>
                </tr>
                {/loop}
                <tr>
                    <td colspan="11">
                        <!--<input type="button" class="btn btn-primary" name="deleteall" value="删除选择的" />-->
						
						
                    </td>
                </tr>
            </tbody>
        </table>
        {$pager}
    </div>
</div>
</div>
<script>
require(['jquery', 'util'], function($, util){
	$('.listbox .js-url a').each(function(){
		util.clip(this),$(this).attr('data-url'));
	});
});
</script>

<script>
            $(function(){

            $(".check_all").click(function(){
            var checked = $(this).get(0).checked;
                    $("input[type=checkbox]").attr("checked", checked);
            });
                    $("input[name=deleteall]").click(function(){

            var check = $("input:checked");
                    if (check.length < 1){
            err('请选择要删除的记录!');
                    return false;
            }
            if (confirm("确认要删除选择的记录?")){
            var id = new Array();
                    check.each(function(i){
                    id[i] = $(this).val();
                    });
                    $.post('{php echo create_url('site/module', array('do' => 'deleteAll', 'name' => 'tyzm_diamondvote'))}', {idArr:id}, function(data){
                    if (data.errno == 0)
                    {
                    location.reload();
                    } else {
                    alert(data.error);
                    }


                    }, 'json');
            }

            });
                    });</script>
<script>
            function drop_confirm(msg, url){
            if (confirm(msg)){
            window.location = url;
            }
            }
			

		

</script>

{template 'common/footer'}